DateRangeBox: improve typing - #34601
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the DateRangeBox implementation to use the non-m_ internal module names and improves TypeScript typings across DateRangeBox, its multiselect DateBox, and related DateBox strategies—primarily by introducing stronger option/event types and reducing @ts-expect-error usage.
Changes:
- Switched DateRangeBox public entry and internal imports from
m_*modules to the newdate_range_*modules. - Tightened types in
Editor,DateRangeBox,MultiselectDateBox, andRangeCalendarStrategy(options, events, and return types). - Standardized keyboard handler typings to use
DxEvent<KeyboardEvent>in DateBox strategies.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme/js/ui/date_range_box.js | Updates the public entry import to the renamed internal DateRangeBox module. |
| packages/devextreme/js/__internal/ui/editor/editor.ts | Broadens editor typing constraint so validationMessagePosition can include 'auto' (Mode) for components that resolve position themselves. |
| packages/devextreme/js/__internal/ui/date_range_box/strategy/rangeCalendar.ts | Refactors RangeCalendar strategy typings (value/event/popup), and aligns keyboard handlers with DxEvent. |
| packages/devextreme/js/__internal/ui/date_range_box/multiselect_date_box.ts | Improves MultiselectDateBox typing, switches to internal DateBox import, and updates event/option handler types. |
| packages/devextreme/js/__internal/ui/date_range_box/m_date_range.utils.ts | Removes legacy m_ utility module. |
| packages/devextreme/js/__internal/ui/date_range_box/date_range.utils.ts | Adds typed DateRangeBox date utilities (getDeserializedDate, comparisons, sorting). |
| packages/devextreme/js/__internal/ui/date_range_box/date_range_box.ts | Reworks DateRangeBox typings (properties, events, option handling) and updates internal dependencies to new module names. |
| packages/devextreme/js/__internal/ui/date_box/date_box.strategy.ts | Updates supportedKeys handler typing to DxEvent<KeyboardEvent>. |
| packages/devextreme/js/__internal/ui/date_box/date_box.strategy.list.ts | Updates supportedKeys handler typing to DxEvent<KeyboardEvent>. |
| packages/devextreme/js/__internal/ui/date_box/date_box.strategy.calendar.ts | Updates supportedKeys handler typing to DxEvent<KeyboardEvent>. |
Suppressed comments (2)
packages/devextreme/js/__internal/ui/date_range_box/strategy/rangeCalendar.ts:196
value[0]is aDateLike(can be0), so a falsy check incorrectly treats valid timestamps like0(Unix epoch) as “missing”. Use a nullish check instead.
This issue also appears on line 215 of the same file.
packages/devextreme/js/__internal/ui/date_range_box/strategy/rangeCalendar.ts:219
- This condition uses
&& value[0]which treats validDateLikevalues like0as absent. Prefer a nullish check so epoch timestamps don’t skip the out-of-range correction.
f2b1f77 to
c99dc9e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
Suppressed comments (3)
packages/devextreme/js/__internal/ui/overlay/overlay.ts:936
- Same generic type mismatch as above: pushing
thisintoOverlay[]may be a TS error ifOverlay<TProperties>is not assignable toOverlay<OverlayProperties>.
Cast this to the stack element type (or adjust OVERLAY_STACK typing).
if (!isInStack) {
this._zIndex = zIndex ?? zIndexPool.create(this._zIndexInitValue());
overlayStack.push(this);
}
packages/devextreme/js/__internal/ui/overlay/overlay.ts:922
- Same generic type mismatch as above:
overlayStack.indexOf(this)may be a TS error ifthis(Overlay) is not assignable toOverlay<OverlayProperties>.
Cast this to the stack element type (or adjust OVERLAY_STACK typing).
_updateZIndexStackPosition(pushToStack: boolean): void {
const overlayStack = this._overlayStack();
const index = overlayStack.indexOf(this);
const isInStack = index !== -1;
const { zIndex } = this.option();
packages/devextreme/js/__internal/ui/drop_down_editor/drop_down_list.ts:221
_initContentReadyActionassigns tothis._contentReadyAction, but the class does not declare_contentReadyAction. Without an existing declaration onDropDownEditor, this is a TypeScript error (property does not exist) and will break compilation.
Declare _contentReadyAction on DropDownList (or move it to the base class if it is shared).
_initContentReadyAction(): void {
this._contentReadyAction = this._createActionByOption('onContentReady', {
excludeValidators: ['disabled', 'readOnly'],
});
}
| const overlayStack = this._overlayStack(); | ||
| const innerOverlayElement = $closestInnerOverlay.get(0); | ||
| // @ts-expect-error this and Overlay have no overlap | ||
| const thisIndex = overlayStack.indexOf(this); |
No description provided.